Skip to content

Conversation

@remo-lab
Copy link
Contributor

The Bug

File: packages/phoenix-event-display/src/managers/three-manager/import-manager.ts
Function: ImportManager.loadGLTFGeometryInternal (Lines 409-445)

When loading GLTF geometries, cloned geometries are collected in materials[key].geoms arrays, merged into a final geometry, but intermediate geometries are never disposed. This leaves orphaned WebGL buffers in GPU memory.

Identical pattern to the leak fixed in phoenix-objects.ts (commit ad79b44) but missed in import-manager.ts.

The Fix

Summary: After BufferGeometryUtils.mergeGeometries(), added disposal loop for all intermediate geometries in the materials object.

Files changed: 1 (import-manager.ts)
Validation: All 166 tests pass + linting clean

Why This Matters

  • GPU memory leaks on every GLTF load → browser crashes after multiple detector geometry loads
  • Physics workflows broken (ATLAS/CMS detector visualization, control rooms, conferences)
  • Silent failure—no errors, just gradual memory exhaustion until OOM
  • Real production impact—common workflow with complex detector geometries

How to Verify

See import-manager.ts diff in this PR. To test locally:

  1. Load any detector GLTF geometry multiple times
  2. Monitor GPU memory via browser DevTools > Performance > Memory or chrome://gpu
  3. Before: Memory grows unbounded
    After: Memory stays stable after each load

Impact

Eliminates crashes during long-running detector visualization sessions. Matches our existing cleanup pattern from phoenix-objects.ts. Zero render behavior change—just proper Three.js resource management.

Signed-off-by: remo-lab <remopanda7@gmail.com>
@remo-lab
Copy link
Contributor Author

remo-lab commented Jan 26, 2026

Hey ,@EdwardMoyse same Three.js disposal pattern from phoenix-objects.ts - just missed in import-manager.ts. All 166 tests pass, linting clean.

would appreciate a review whenever you get time! Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant